﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserMenuList.aspx.cs" Inherits="GU.WebERPApp.Sys.UserMenuList" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">
        body, form, html
        {
            overflow: visible;
            width: 800px;
            height: 100%;
            margin:5 0 0 5;
            padding:0;
        }
    </style>
    <script src="/Scripts/mini.boot.js" type="text/javascript"></script>
    <script src="/Scripts/CodeData.js" type="text/javascript"></script>
</head>
<body>
    <div id="dvSearch" class="mini-toolbar">
        用户名：<input id="txtUserName" name="UserName" class="mini-textbox" style="width:100px;" onenter="searchUser"/>
        <span class="separator"></span>
        是否管理员：<input id="cboIsAdmin" name="IsAdmin" style="width:60px;" class="mini-combobox" textfield="text"
                    valuefield="id" shownullitem="true" nullitemtext="" />
        <span class="separator"></span>
        开始日期：<input id="start" class="mini-datepicker" style="width: 100px;" format="yyyy-MM-dd" />
        <span class="separator"></span>
        结束日期：<input id="end" class="mini-datepicker" style="width: 100px;" format="yyyy-MM-dd" />
        <a class="mini-button" iconcls="icon-search" plain="false" style="float:right;" onclick="searchUser()">
                查询</a>
    </div>
    <div id="dvOperation" style="margin:5px 0;">
        <a id="btnAdd" class="mini-button" iconcls="icon-add" plain="true" onclick="addUser()">新增用户</a>
        <!--a id="btnEdit" class="mini-button" iconcls="icon-edit" plain="true" onclick="editUser()">修改用户</a>
        <a id="btnDelete" class="mini-button" iconcls="icon-remove" plain="true" onclick="deleteUser()">删除用户</a-->
    </div>
    <div class="mini-fit">
        <div id="grid_usermenu" class="mini-datagrid" style="width: 100%; height: 100%;"
            allowalternating="true" idfield="CommodityVoteId" pagesize="20" showFooter="false"
            multiselect="true" url="/methods/?method=itm.sys.usermenu.get">
            <div property="columns">
                <div type="indexcolumn" width="20"></div>
                <div field="UserName" headeralign="center" align="center" width="50">
                    用户名</div>
                <div field="IsAdmin" headeralign="center" align="center" width="50" renderer="onIsAdminRenderer">
                    是否管理员</div>
                <div field="Remark" headeralign="center" align="right">
                    备注</div>
                <div field="Rec_CreateTime" align="center" headeralign="center"
                    dateformat="yyyy-MM-dd" width="100">
                    创建日期</div>
                <div name="action" width="60" headeralign="center" align="center" renderer="onActionRenderer">
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">

        $(document).ready(function () {
            mini.get("cboIsAdmin").setData(_CodeData.YesNo);
            searchUser();
        });

        function searchUser() {
            mini.get("grid_usermenu").load();
        }

        function addUser() {
            _Popups.open("UserMenuEdit.aspx?type=add", "新增用户", "510px", "340px", null, function () { mini.get("grid_usermenu").reload(); });
        }

        function editUser() {
            var row = mini.get("grid_usermenu").getSelected();
            _Popups.open("UserMenuEdit.aspx?type=edit&id=" + row.UserId, "修改用户", "510px", "340px", null, function () { mini.get("grid_usermenu").reload(); });
        }

        function gridReload() {
            mini.get("grid_usermenu").reload();
        }

        function deleteUser() {
            var row = mini.get("grid_usermenu").getSelected();
            mini.confirm("确定是否删除用户 “" + row.UserName + "” ？", "删除", function (action) {
                if (action == "ok") {
                    ygopAjaxClient.async("itm.sys.usermenu.delete", "post", { "uid": row.UserId }, function (e) {
                        if (e.RspCode == 1) {
                            $.alert(e.RspMsg);
                            gridReload();
                        }
                        else {
                            mini.alert(e.RspMsg);
                        }
                    });
                }
            });
        }

        function onIsAdminRenderer(e) {
            var record = e.record;
            return _JsonHelper.getText(_CodeData.YesNo, record.IsAdmin);
        }

        function onActionRenderer() {
            return "<a href='javascript:editUser();'>修改</a>&nbsp;&nbsp;&nbsp;<a href='javascript:deleteUser();'>删除</a>";
        }

        function closePage() {
            _Popups.close();
        }
    </script>
</body>
</html>
